package org.jeecg.modules.motorVehicle.entity;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

@Setter
@Getter
public class CarSummary {
    public String companyName;
    public String orgCode;
    public String companyLevel;
    public BigDecimal bookQuantity;
    public BigDecimal bookNetValue;
    public BigDecimal bookOriginalValue;
    public List<TbMotorVehicleInventoryDetails> motorVehicleList; // 存储汇总所基于的原始数据

    public CarSummary(String companyName, String orgCode, String companyLevel, BigDecimal bookQuantity, BigDecimal bookNetValue, BigDecimal bookOriginalValue, List<TbMotorVehicleInventoryDetails> motorVehicleList) {
        this.companyName = companyName;
        this.orgCode = orgCode;
        this.companyLevel = companyLevel;
        this.bookQuantity = bookQuantity;
        this.bookNetValue = bookNetValue;
        this.bookOriginalValue = bookOriginalValue;
        this.motorVehicleList = motorVehicleList;
    }

    public void addBookQuantity(BigDecimal bookQuantity) {
        if (this.bookQuantity == null) {
            this.bookQuantity = BigDecimal.ZERO;
        }
        if (bookQuantity != null) {
            this.bookQuantity = this.bookQuantity.add(bookQuantity);
        }
    }

    public void addBookNetValue(BigDecimal bookNetValue) {
        if (this.bookNetValue == null) {
            this.bookNetValue = BigDecimal.ZERO;
        }
        if (bookNetValue != null) {
            this.bookNetValue = this.bookNetValue.add(bookNetValue);
        }
    }

    public void addBookOriginalValue(BigDecimal bookOriginalValue) {
        if (this.bookOriginalValue == null) {
            this.bookOriginalValue = BigDecimal.ZERO;
        }
        if (bookOriginalValue != null) {
            this.bookOriginalValue = this.bookOriginalValue.add(bookOriginalValue);
        }
    }



    // 深拷贝方法
    public CarSummary deepCopy() {
        return new CarSummary(
                this.companyName,
                this.orgCode,
                this.companyLevel,
                this.bookQuantity,
                this.bookNetValue,
                this.bookOriginalValue,
                this.motorVehicleList
        );
    }
}
